dat <- read.csv("../result/wgt_x.csv")
wx = dat$w_ols[dat$x>5]
sx = dat$w_ols_se[dat$x>5]
wz = dat$w_iv[dat$x>5]
sz = dat$w_iv_se[dat$x>5]

hz = wz + sz
lz = wz - sz
uni = 0.25
high <- 1
low <- 0
scales= round( seq(low,high,by=uni),digits=2 )
eps = 0.1
eta = 0.25

xx = 6:20
xl = c(0,20)
yl = c(-0.02,1.02)
pdf('../result/wgt_x_br.pdf')
par(mar=c(6.1,5.3,2.1,2.1),mgp=c(4.5,1,0),las=1)
plot(xx,wz,type="o",lwd=1.5,cex=1.75,lty=2,pch=16,col='#e31a1c',ylim=yl,xlim=xl,xlab="",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
plot(xx,wx,type="o",lwd=1.5,cex=1.75,lty=2,pch=17,ylim=yl,xlim=xl,xlab="Years of education",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
segments(xx,lz,xx,hz,lwd=1.5,col='#e31a1c')
segments(xx-eps,lz,xx+eps,lz,lwd=1.5,col='#e31a1c')
segments(xx-eps,hz,xx+eps,hz,lwd=1.5,col='#e31a1c')
par(new=T,las=1)
abline(h=0,lty=3,lwd=3.0)
#par(new=T,las=1)
#abline(v=12,lty=3,lwd=3.0) # high school completion (11->12)
#par(new=T,las=1)
#abline(v=16,lty=3,lwd=3.0) # college completion (15->16)
par(new=T,las=1)
axis(1, at=c(0,4,8,12,16,20), cex.axis=1.6)
axis(2, at=scales, cex.axis=1.6, lab=format(scales,nsmall=0) )
dev.off()

dat <- read.csv("../result/wgt_x_NI.csv")
wx = dat$w_ols[dat$x>5]
sx = dat$w_ols_se[dat$x>5]
wz = dat$w_iv[dat$x>5]
sz = dat$w_iv_se[dat$x>5]

hz = wz + sz
lz = wz - sz
uni = 0.15
high <- 0.60
low <- 0
scales= round( seq(low,high,by=uni),digits=2 )
eps = 0.1
eta = 0.25

xx = 6:20
xl = c(0,20)
yl = c(-0.02,0.62)
pdf('../result/wgt_x_ni.pdf')
par(mar=c(6.1,5.3,2.1,2.1),mgp=c(4.5,1,0),las=1)
plot(xx,wz,type="o",lwd=1.5,cex=1.75,lty=2,pch=16,col='#e31a1c',ylim=yl,xlim=xl,xlab="",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
plot(xx,wx,type="o",lwd=1.5,cex=1.75,lty=2,pch=17,ylim=yl,xlim=xl,xlab="Years of education",ylab="",cex.axis=1.6,cex.lab=2.0,xaxt='n',yaxt='n')
par(new=T,las=1)
segments(xx,lz,xx,hz,lwd=1.5,col='#e31a1c')
segments(xx-eps,lz,xx+eps,lz,lwd=1.5,col='#e31a1c')
segments(xx-eps,hz,xx+eps,hz,lwd=1.5,col='#e31a1c')
par(new=T,las=1)
abline(h=0,lty=3,lwd=3.0)
#par(new=T,las=1)
#abline(v=12,lty=3,lwd=3.0) # high school completion (11->12)
#par(new=T,las=1)
#abline(v=16,lty=3,lwd=3.0) # college completion (15->16)
par(new=T,las=1)
axis(1, at=c(0,4,8,12,16,20), cex.axis=1.6)
axis(2, at=scales, cex.axis=1.6, lab=format(scales,nsmall=0) )
dev.off()